package tx_chat

import (
	"longmen/server/internal/rpc/tencentim/subscribe"
	"sync"

	"go.uber.org/zap"
)

// TxAnonymousLogin 匿名登录消息
type TxAnonymousLogin struct {
	logger *zap.SugaredLogger
	tx     *subscribe.TxChat
}

var anonymous *TxAnonymousLogin
var anonymousOnce sync.Once

func NewAnonymousLogin(log *zap.SugaredLogger) *TxAnonymousLogin {
	anonymousOnce.Do(func() {
		anonymous = &TxAnonymousLogin{
			logger: log,
			tx:     subscribe.NewTxChat(log),
		}
	})
	return anonymous
}

func (t *TxAnonymousLogin) Process(data []byte) bool {
	return t.tx.AnoLoginBroadcast(data)
}
